/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package classcreator;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;

/**
 *
 * @author Stefano
 */
public class State {
    private static double outputFormatVersion=1.0;
    
    public int id;
    public String name;
    
    public State(int i, String n){
        id=i;
        name=n;
    }
    
    public boolean equals(State s){
        return id==s.id && name.equals(s.name);
    }
    
    public static State parse(BufferedReader br, TypeRepository tr) throws IOException{
                br.readLine();
                double version=Double.parseDouble(br.readLine());
                
                if(version<=1.0){
                    int i=Integer.parseInt(br.readLine());
                    return new State(i,br.readLine());
                }
                //Actual version
                int i=Integer.parseInt(br.readLine());
                return new State(i,br.readLine());
    }
    
    public void permanentize(BufferedWriter br, TypeRepository tr) throws IOException{
        br.write("/***/ State: "+name); br.newLine();
        br.write(String.valueOf(outputFormatVersion)); br.newLine();
            br.write(String.valueOf(id)); br.newLine();
            br.write(name); br.newLine();
    }
}
